home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 21 / AACD 21.iso / AACD / Utilities / Ghostscript / src / gsbitmap.h < prev    next >
Encoding:
C/C++ Source or Header  |  2001-01-01  |  8.4 KB  |  200 lines

  1. /* Copyright (C) 1998, 1999 Aladdin Enterprises.  All rights reserved.
  2.   
  3.   This file is part of AFPL Ghostscript.
  4.   
  5.   AFPL Ghostscript is distributed with NO WARRANTY OF ANY KIND.  No author or
  6.   distributor accepts any responsibility for the consequences of using it, or
  7.   for whether it serves any particular purpose or works at all, unless he or
  8.   she says so in writing.  Refer to the Aladdin Free Public License (the
  9.   "License") for full details.
  10.   
  11.   Every copy of AFPL Ghostscript must include a copy of the License, normally
  12.   in a plain ASCII text file named PUBLIC.  The License grants you the right
  13.   to copy, modify and redistribute AFPL Ghostscript, but only under certain
  14.   conditions described in the License.  Among other things, the License
  15.   requires that the copyright notice and this notice be preserved on all
  16.   copies.
  17. */
  18.  
  19. /*$Id: gsbitmap.h,v 1.2 2000/09/19 19:00:25 lpd Exp $ */
  20. /* Library "client" bitmap structures */
  21.  
  22. #ifndef gsbitmap_INCLUDED
  23. #define gsbitmap_INCLUDED
  24.  
  25. #include "gsstype.h"        /* for extern_st */
  26.  
  27. /*
  28.  * The Ghostscript library stores all bitmaps bit-big-endian (i.e., the 0x80
  29.  * bit of the first byte corresponds to x=0), as a sequence of bytes (i.e.,
  30.  * you can't do word-oriented operations on them if you're on a
  31.  * little-endian platform like the Intel 80x86 or VAX).  The first scan line
  32.  * corresponds to y=0 in whatever coordinate system is relevant.
  33.  *
  34.  * The structures defined here are for APIs that don't impose any alignment
  35.  * restrictions on either the starting address or the raster (distance
  36.  * between scan lines) of bitmap data.  The structures defined in gxbitmap.h
  37.  * do impose alignment restrictions, so that the library can use more
  38.  * efficient algorithms; they are declared with identical contents to the
  39.  * ones defined here, so that one can cast between them under appropriate
  40.  * circumstances (aligned to unaligned is always safe; unaligned to
  41.  * aligned is safe if one knows somehow that the data are actually aligned.)
  42.  *
  43.  * In this file we also provide structures that include depth information.
  44.  * It probably was a design mistake not to include this information in the
  45.  * gx structures as well.
  46.  */
  47.  
  48. /*
  49.  * Drivers such as the X driver and the command list (band list) driver
  50.  * benefit greatly by being able to cache bitmaps (tiles and characters)
  51.  * and refer to them later.  To help them recognize when a bitmap is the
  52.  * same as one that they have seen before, the core code passes an optional
  53.  * ID with the property that if two bitmaps have the same ID, they are
  54.  * guaranteed to have the same contents.  (The converse is *not* true,
  55.  * however: two bitmaps may have different IDs and still be the same.)
  56.  */
  57. typedef gs_id gs_bitmap_id;
  58.  
  59. /* Define a special value to indicate "no identifier". */
  60. #define gs_no_bitmap_id     gs_no_id
  61.  
  62. /*
  63.  * In its simplest form, the client bitmap structure does not specify a
  64.  * depth, expecting it to be implicit in the context of use.  In many cases
  65.  * it is possible to guess this by comparing size.x and raster, but of
  66.  * course code should not rely on this.  See also gs_depth_bitmap below.
  67.  * Requirements:
  68.  *      size.x > 0, size.y > 0
  69.  *      If size.y > 1,
  70.  *          raster >= (size.x * depth + 7) / 8
  71.  */
  72. #define gs_bitmap_common(data_type)                                         \
  73.     data_type *     data;       /* pointer to the data */                   \
  74.     int             raster;     /* increment between scanlines, bytes */    \
  75.     gs_int_point    size;       /* width and height */                      \
  76.     gs_bitmap_id    id        /* usually unused */
  77.  
  78. typedef struct gs_bitmap_s {
  79.     gs_bitmap_common(byte);
  80. } gs_bitmap;
  81. typedef struct gs_const_bitmap_s {
  82.     gs_bitmap_common(const byte);
  83. } gs_const_bitmap;
  84.  
  85. /*
  86.  * For bitmaps used as halftone tiles, we may replicate the tile in
  87.  * X and/or Y, but it is still valuable to know the true tile dimensions
  88.  * (i.e., the dimensions prior to replication).  Requirements:
  89.  *      size.x % rep_width = 0
  90.  *      size.y % rep_height = 0
  91.  * Unaligned bitmaps are not very likely to be used as tiles (replicated),
  92.  * since most of the library procedures that replicate tiles expect them
  93.  * to be aligned.
  94.  */
  95. #define gs_tile_bitmap_common(data_type)                          \
  96.     gs_bitmap_common(data_type);                                  \
  97.     ushort      rep_width, rep_height    /* true size of tile */
  98.  
  99. typedef struct gs_tile_bitmap_s {
  100.     gs_tile_bitmap_common(byte);
  101. } gs_tile_bitmap;
  102. typedef struct gs_const_tile_bitmap_s {
  103.     gs_tile_bitmap_common(const byte);
  104. } gs_const_tile_bitmap;
  105.  
  106. /*
  107.  * There is no "strip" version for client bitmaps, as the strip structure is
  108.  * primarily used to efficiently store bitmaps rendered at an angle, and
  109.  * there is little reason to do so with client bitmaps.
  110.  *
  111.  * For client bitmaps it is not always apparent from context what the intended
  112.  * depth per sample value is. To provide for this, an extended version of the
  113.  * bitmap structure is provided, that handles both variable depth and
  114.  * interleaved color components. This structure is provided in both the
  115.  * normal and tiled version.
  116.  *
  117.  * Extending this line of thinking, one could also add color space information
  118.  * to a client bitmap structure. We have chosen not to do so, because color
  119.  * space is almost always derived from context, and to provide such a feature
  120.  * would involve additional memory-management complexity.
  121.  */
  122. #define gs_depth_bitmap_common(data_type)                           \
  123.     gs_bitmap_common(data_type);                                    \
  124.     byte     pix_depth;      /* bits per sample */                  \
  125.     byte     num_comps      /* number of interleaved components */  \
  126.  
  127. typedef struct gs_depth_bitmap_s {
  128.     gs_depth_bitmap_common(byte);
  129. } gs_depth_bitmap;
  130. typedef struct gs_const_depth_bitmap_s {
  131.     gs_depth_bitmap_common(const byte);
  132. } gs_const_depth_bitmap;
  133.  
  134. #define gs_tile_depth_bitmap_common(data_type)                      \
  135.     gs_tile_bitmap_common(data_type);                               \
  136.     byte     pix_depth;     /* bits per sample */                   \
  137.     byte     num_comps      /* number of interleaved components */  \
  138.  
  139. typedef struct gs_tile_depth_bitmap_s {
  140.     gs_tile_depth_bitmap_common(byte);
  141. } gs_tile_depth_bitmap;
  142. typedef struct gs_const_tile_depth_bitmap_s {
  143.     gs_tile_depth_bitmap_common(const byte);
  144. } gs_const_tile_depth_bitmap;
  145.  
  146. /*
  147.  * For reasons that are no entirely clear, no memory management routines were
  148.  * provided for the aligned bitmap structures provided in gxbitmap.h. Since
  149.  * client bitmaps will, by nature, be created by different clients, so public
  150.  * memory management procedures are provided. Note that the memory management
  151.  * structure names retain the "gs_" prefix, to distinguish these structures
  152.  * from those that may be provided for the gx_*_bitmap structures.
  153.  *
  154.  * For historical reasons of no particular validity (this was where the client
  155.  * bitmap structure was first provided), the memory managment procedures for
  156.  * client bitmap structures are included in gspcolor.c.
  157.  */
  158. extern_st(st_gs_bitmap);
  159. extern_st(st_gs_tile_bitmap);
  160. extern_st(st_gs_depth_bitmap);
  161. extern_st(st_gs_tile_depth_bitmap);
  162.  
  163. #define public_st_gs_bitmap()   /* in gspcolor.c */ \
  164.     gs_public_st_ptrs1( st_gs_bitmap,               \
  165.                         gs_bitmap,                  \
  166.                         "client bitmap",            \
  167.                         bitmap_enum_ptrs,           \
  168.                         bitmap_reloc_ptrs,          \
  169.                         data                        \
  170.                         )
  171.  
  172. #define public_st_gs_tile_bitmap()  /* in gspcolor.c */ \
  173.     gs_public_st_suffix_add0_local( st_gs_tile_bitmap,        \
  174.                     gs_tile_bitmap,           \
  175.                     "client tile bitmap",     \
  176.                     bitmap_enum_ptrs,    \
  177.                     bitmap_reloc_ptrs,   \
  178.                     st_gs_bitmap              \
  179.                     )
  180.  
  181. #define public_st_gs_depth_bitmap() /* in gspcolor.c */ \
  182.     gs_public_st_suffix_add0_local( st_gs_depth_bitmap,       \
  183.                     gs_depth_bitmap,          \
  184.                     "client depth bitmap",    \
  185.                     bitmap_enum_ptrs,   \
  186.                     bitmap_reloc_ptrs,  \
  187.                     st_gs_bitmap              \
  188.                     )
  189.  
  190. #define public_st_gs_tile_depth_bitmap()/* in gspcolor.c */ \
  191.     gs_public_st_suffix_add0_local( st_gs_tile_depth_bitmap,      \
  192.                     gs_tile_depth_bitmap,         \
  193.                     "client tile_depth bitmap",   \
  194.                     bitmap_enum_ptrs,  \
  195.                     bitmap_reloc_ptrs, \
  196.                     st_gs_tile_bitmap             \
  197.                     )
  198.  
  199. #endif /* gsbitmap_INCLUDED */
  200.